<SCRIPT language="JavaScript" type=text/javascript>
/*
 * Ext JS Library 2.0
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
Ext.BLANK_IMAGE_URL = 'ext-2.1/resources/images/default/s.gif';
var mainTabs;

Ext.onReady(function(){
	Ext.QuickTips.init();
	//Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
			
    mainTabs = new Ext.TabPanel({
	    region:         'center',
	    deferredRender: false,
	    activeTab:      0,
	    items:[
			<?
			// Populate page tabs based on $siteAreaArray
			$items = '';
			$noOfItems = count($siteAreaArray[SITE_AREA]);
			for($a=0;$a<=($noOfItems-1);$a++) {
				$items .= "{ id: 'pageTab".$a."', contentEl: 'content".$a."', title: '".$siteAreaArray[SITE_AREA][$a]."', autoScroll: true, listeners: {activate: viewTabContent.content".$a."Load}},\n";
			}
			// Remove trailing ,
			$items = substr($items, 0, -2);
			echo $items;
		    ?>
		]
	});
    
    var viewport = new Ext.Viewport({
        layout:'border',
        items:[
			new Ext.BoxComponent({
                region: 'north',
                el:     'north',
                height: 55
            })
            <? if (SITE_AREA != 'login') { ?>
            ,{
            	id: 'panelMessages',
	            region:        'south',
	            contentEl:     'south',
	            iconCls:       'iconMessages',
	            autoScroll:    true,
	            split:         true,
	            height:        300,
	            minSize:       100,
	            maxSize:       400,
	            collapsible:   true,
	            title:         'Messages',
	            collapsed:     true,
	            margins:       '0 0 0 0',
	            autoLoad: {url:"includes/dashboard/windowMessages.php", scripts:true},
	            tbar:[{
                        tooltip:'Create new message',
                        text: 'New Message',
                        iconCls:'toolbarNewMessage',
						handler : function(){
			                messageSupportObj.openNewMessageForm();
			            }
                    }]
            },{
	            region:      'west',
	            id:          'west-panel',
	            title:       'Toolbox',
	            split:        true,	            
	            width:        200,
	            minSize:      175,
	            maxSize:      400,
	            collapsible:  true,
	            margins:      '0 0 5 5',
	            cmargins:     '0 5 5 5',
	            layout:       'accordion',
	            layoutConfig: { animate:true },
		            items: [{
		                title:'Main Menu',
		                border:false,
		                autoScroll:true,
		                iconCls:'iconNav',
		                autoLoad: {url:"includes/menuMain.php", scripts:true}
		            },
		            <? if ($thisPage != 'calendar.php') { ?>		            
		            {
		                title:'Calendar',
		                border:false,
		                autoScroll:true,
		                iconCls:'iconCalendar',
		                autoLoad: {url:"includes/dashboard/windowCalendar.php?config=sidebar", scripts:true}
		            },
		            <? } ?>
		            {
		                title:'Exports &amp; Downloads',
		                border:false,
		                autoScroll:true,
		                iconCls:'iconDownload',
						autoLoad: {url:"includes/dashboard/windowDownload.php?config=sidebar", scripts:true}
		            },{
		                title:'Settings',
		                border:false,
		                autoScroll:true,
		                iconCls:'iconSettings',
						autoLoad: {url:"includes/dashboard/windowSettings.php", scripts:true}
		            }]
	        }
	        <? } ?>
	        ,
	        mainTabs
	        ]
	    }); 
	    
	    /*
	     * From appInit.php
	     * $onLoad var will be viewTabContent.content[GET[tab]]Load();
	     */
	    <?=$onLoad; ?>   
	    
	    /*
	     * Get number of items in trash
	     */
	     trashRenderObj.getNumberItemsInTrash('head');	     
});
</script>